package com.spring.sunflower.bean

import android.os.Parcel
import android.os.Parcelable

/**
 * Created by Kevin on 2021/7/30<br/>
 *
 * Describe:<br/>
 * 话题库
 */
data class TalkRepositoryBeanX(
    val datas: List<Data>,
    val message: String,
    val status: String
) : Parcelable {
    data class Data(
        val contentArray: List<ContentArray>,
        val tag: String
    ) : Parcelable {
        data class ContentArray(
            val content: String,
            val id: String,
            val title: String,
            val type: String
        ) : Parcelable {
            constructor(parcel: Parcel) : this(
                parcel.readString()!!,
                parcel.readString()!!,
                parcel.readString()!!,
                parcel.readString()!!
            ) {
            }

            override fun describeContents(): Int {
                return this.hashCode()
            }

            override fun writeToParcel(dest: Parcel?, flags: Int) {
                dest?.let {
                    it.writeString(content)
                    it.writeString(id)
                    it.writeString(title)
                    it.writeString(type)
                }
            }

            companion object CREATOR : Parcelable.Creator<ContentArray> {
                override fun createFromParcel(parcel: Parcel): ContentArray {
                    return ContentArray(parcel)
                }

                override fun newArray(size: Int): Array<ContentArray?> {
                    return arrayOfNulls(size)
                }
            }
        }

        constructor(parcel: Parcel) : this(
            parcel.createTypedArrayList(ContentArray)!!,
            parcel.readString()!!
        ) {
        }

        override fun describeContents(): Int {
            return this.hashCode()
        }

        override fun writeToParcel(dest: Parcel?, flags: Int) {
            dest?.let {
                it.writeList(contentArray)
                it.writeString(tag)
            }
        }

        companion object CREATOR : Parcelable.Creator<Data> {
            override fun createFromParcel(parcel: Parcel): Data {
                return Data(parcel)
            }

            override fun newArray(size: Int): Array<Data?> {
                return arrayOfNulls(size)
            }
        }
    }

    constructor(parcel: Parcel) : this(
        parcel.createTypedArrayList(Data)!!,
        parcel.readString()!!,
        parcel.readString()!!
    ) {
    }

    override fun describeContents(): Int {
        return this.hashCode()
    }


    override fun writeToParcel(dest: Parcel?, flags: Int) {
        dest?.let {
            it.writeList(datas)
            it.writeString(message)
            it.writeString(status)
        }
    }

    companion object CREATOR : Parcelable.Creator<TalkRepositoryBeanX> {
        override fun createFromParcel(parcel: Parcel): TalkRepositoryBeanX {
            return TalkRepositoryBeanX(parcel)
        }

        override fun newArray(size: Int): Array<TalkRepositoryBeanX?> {
            return arrayOfNulls(size)
        }
    }
}


